
const getDefaultState = () => {
  return {
    testName: ''
  }
}

const state = getDefaultState()

const mutations = {
  // 重置默认数据
  RESET: (state) => {
    Object.assign(state, getDefaultState())
  },
  SET_NAME: (state, name) => {
    state.testName = name
  }
}

const actions = {
  setName({ commit, state }, data) {
    return new Promise((resolve, reject) => {
      console.log(state)
      // if(){
      //   reject(error)
      // }
      commit('SET_NAME', data)
      resolve()
    })
  },
  reset({ commit }) {
    return new Promise((resolve, reject) => {
      commit('RESET')
      resolve()
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
